import { ADD, REDUCE } from "../constant"

/* 
    用来记录所有action对象方便调用
*/
// 同步action,就是指action的返回值为ocject类型的一般对象
export const add = data => ({ type: ADD, data })
export const reduce = data => ({ type: REDUCE, data })

// 异步action,就是指action的返回值为函数类型,,异步action中一般会调用同步action
export const addAsync = (data, time) => {
    return (dispatch) => {
        setTimeout(() => { dispatch(add(data)) }, time)
    }
}